<?php
/**
 * Created by PhpStorm.
 * User: zhaoyi
 * Date: 2022/1/26
 * Time: 11:46.
 */

declare(strict_types=1);

namespace App\Application\Api\Controller;

use App\Annotation\Api;
use App\Application\Admin\Model\Member;
use App\Application\Admin\Model\Store;
use App\Application\Admin\Service\AdminSettingService;
use Hyperf\DbConnection\Db;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\Controller;

#[Controller("/api/member/")]
class MemberController extends AbstractController
{
    #[Inject]
    protected AdminSettingService $setting;


    /*
     *
     *轮播图
     * */
    #[Api]
    #[PostMapping("info")]
    function info()
    {
        $token = $this->request->header('token', '');
        $appid = $this->request->header('appid', '');
        $member = Member::where('token', $token)->where('appid', $appid)->select('*')
            ->first() ?: [];
        $member['store'] = Store::where('member_id', '=', $member['member_id'])->select('*')->get() ?: [];
        return $member ? compact('member') : $this->returnErrorJson();
    }

}